import 'package:flutter/material.dart';
import 'package:Lter/model/phone.dart';

// 定义一个回调接口
typedef OnItemClickListener = void Function(int position);

class PhoneListItem extends StatelessWidget {
  int position;
  PhoneInfo mPhoneInfo;
  OnItemClickListener listener;

  PhoneListItem(this.position, this.mPhoneInfo, this.listener);

  @override
  Widget build(BuildContext context) {
    var widget = Column(
      children: <Widget>[
        ExpansionTile(
          key: PageStorageKey<PhoneInfo>(mPhoneInfo),
          title: Text(mPhoneInfo.TellNum),
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text("\t\t\t\t\tIMSI:"),
                Text(mPhoneInfo.Imsi + "\t\t\t\t\t"),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text("\t\t\t\t\tOn Time:"),
                Text(mPhoneInfo.OnTime + "\t\t\t\t\t"),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text("\t\t\t\t\tLter Addr:"),
                Text(mPhoneInfo.LterAddr + "\t\t\t\t\t"),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text("\t\t\t\t\tPcap Count:"),
                Text(mPhoneInfo.PcapCount.toString() + "\t\t\t\t\t"),
              ],
            ),
          ],
        ),
      ],
    );
    //InkWell点击的时候有水波纹效果
    return InkWell(onTap: () => listener(position), child: widget);
  }
}
